﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IndentationSplitter.Tests
{
    [TestClass]
    public class IndentationConverterTests
    {
        [TestMethod, TestCategory("UnitTest")]
        public void GivenATextWithTabIndentationIgnoresIt()
        {
            const string indentedText = "line1\tline2\t\tline3\tline2";
            var converter = new IndentationFormat(indentedText);
            
            Assert.AreEqual("\t", converter.IndentationString);
            Assert.AreEqual(indentedText, converter.TabbedText);
        }

        [TestMethod, TestCategory("UnitTest")]
        public void GivenAStringWithFourSpaceIndentationIdentifiesIt()
        {
            const string indented = @"item1
    item2
        item3";

            var converter = new IndentationFormat(indented);
            Assert.AreEqual("    ", converter.IndentationString);
        }

        [TestMethod, TestCategory("UnitTest")]
        public void GivenAStringWithSingleSpaceIndentationReplacesIt()
        {
            const string indented = @"item1
 item2
  item3
 item4
  item5";

            var conveter = new IndentationFormat(indented);
            Assert.AreEqual(" ", conveter.IndentationString);
            Assert.AreEqual(indented.Replace(" ", "\t"), conveter.TabbedText);
        }
    }
}
